package com.school.controller;

import com.school.entity.Student;
import com.school.service.impl.StuServiceImpl;
import com.school.util.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StuController {
    @Resource
    StuServiceImpl stuService;
    @PostMapping("/check")
    public Result getStu(@RequestParam(value = "tname")String tname) {
        Student stu = stuService.findByName(tname);
        System.out.println(tname);
        if (stu == null) {
            return new Result(200, "该用户名可用", null);
        } else {
            return new Result(400, "该用户名已存在", null);
        }
    }
}
